const http = require("http")
const host = "127.0.0.1";
const port = 3002
const server = http.createServer();
const fs = require("fs")
const readStream = fs.createReadStream("./html/demo.html")
server.on("request", (requstMsg, respone) => {
    console.log("请求来了",requstMsg.headers)
    // console.log(requstMsg.url)
    requstMsg.on("data",(data)=>{
        console.log("data:",data.toString());
    })

    respone.setHeader("Content-Type","text/plain;charset=utf-8;")
    readStream.pipe(respone)

})
server.listen(port, host, () => {
    console.log("服务启动了")
})